package zsc.nine.onlinemall.mapper;


import org.apache.ibatis.annotations.*;
import zsc.nine.onlinemall.entity.Feedback;

import java.util.List;
@Mapper
public interface FeedbackMapper {
    //增，反馈
    @Insert("insert into t_feedback values(#{id},#{userName},#{problem},#{content},#{isRead},#{userEmail},#{createDate})")
    boolean addFeedback(Feedback feedback);

    //删，反馈  ByEmail
    @Delete("delete from t_feedback where userEmail=#{userEmail}")
    boolean deleteFeedbackByEmail(String userEmail);

    //删，反馈   ById
    @Delete("delete from t_feedback where id=#{id}")
    boolean deleteFeedbackById(int id);

    //改，状态  by id
    @Update("update t_feedback set isRead=#{isRead} where id=#{id}")
    boolean updateRead(int id,boolean isRead);

    //查，所有(后台调用)
    @Select("select * from t_feedback")
    List<Feedback> findAll();

    //查，该用户所有反馈（前台调用）
    @Select("select * from t_feedback where userEmail=#{userEmail}")
    List<Feedback> findAllByEmail(String userEmail);

    //查，一个  by id
    @Select("select * from t_feedback where id=#{id}")
    Feedback findById(int id);
}
